# Contributor: TBK <alpine@jjtc.eu>
# Maintainer: Rasmus Thomsen <oss@cogitri.dev>
pkgname=libportal
pkgver=0.6
pkgrel=0
pkgdesc="GIO-style async APIs for most Flatpak portals"
url="https://github.com/flatpak/libportal"
# riscv64: gtk4.0 missing
arch="all !riscv64"
license="LGPL-3.0-or-later"
makedepends="
	meson
	glib-dev
	gtk-doc
	gobject-introspection-dev
	vala
	gtk+3.0-dev
	qt5-qtbase-dev
	qt5-qttools-dev
	qt5-qtx11extras-dev
	"
checkdepends="xvfb-run"
subpackages="
	$pkgname-dev
	$pkgname-gtk3:_gtk3
	$pkgname-qt5:_qt5
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/flatpak/libportal/archive/$pkgver.tar.gz"

_backends="gtk3,qt5"
case "$CARCH" in
	s390x) ;;
	*)
		makedepends="$makedepends gtk4.0-dev"
		subpackages="$subpackages $pkgname-gtk4:_gtk4"
		_backends="$_backends,gtk4"
		;;
esac

build() {
	abuild-meson \
		-Dbackends=$_backends \
		-Ddocs=false \
		. output
	meson compile ${JOBS:+-j ${JOBS}} -C output
}

check() {
	xvfb-run -s '-nolisten local' -a meson test -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

_gtk3() {
	pkgdesc="$pkgdesc (GTK+3.0 backend)"
	# for gobject instrospection
	depends="$pkgname=$pkgver-r$pkgrel"

	amove usr/lib/libportal-gtk3*
	amove usr/lib/girepository-1.0/XdpGtk3*
}

_gtk4() {
	pkgdesc="$pkgdesc (GTK4.0 backend)"
	# for gobject instrospection
	depends="$pkgname=$pkgver-r$pkgrel"

	amove usr/lib/libportal-gtk4*
	amove usr/lib/girepository-1.0/XdpGtk4*
}

_qt5() {
	pkgdesc="$pkgdesc (Qt5 backend)"
	depends=""

	amove usr/lib/libportal-qt5*
}

sha512sums="
c32978b4d818e8a6cfd15bdde7f13d15b69583fa4528c9f45fd294fab6f5b4012e3bea47a6ccf353f70d84e1786331c5f4f94941dd3315684258e403ace5eafc  libportal-0.6.tar.gz
"
